package com.school;

import java.util.ArrayList;
import java.util.Scanner;

public class ArrayListTest1 {
    public static void main(String[] args) {
        //集合的遍历
        ArrayList<String>list=new ArrayList<>();
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入内容：");
        for (int i = 0; i < 3; i++) {
            list.add(sc.nextLine());
        }
        System.out.println(list);

        ArrayList<Integer> list1=new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            list1.add(sc.nextInt());
        }
        System.out.println(list1);

        //如果要添加字符类型的数据，用<Character>
        //以下我不做举例了
    }
}
